﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ThongKe_Change : System.Web.UI.Page
{
    BieumauDataContext db = new BieumauDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btblost_pass_Click(object sender, EventArgs e)
    {
        string mdv = Session["MaDonVi"].ToString().Trim();
        int count_mk = (from p in db.tblDoanhNghiepTuNhans where p.MatKhau == txtmk.Text.Trim().MD5_pass_kieu1() && p.MaDoanhNghiep == mdv select p).Count();
        if (count_mk != 0)
        {
            tblDoanhNghiepTuNhan nn = db.tblDoanhNghiepTuNhans.Single(p => p.MaDoanhNghiep == mdv);
            nn.MatKhau = txtmk_new.Text.Trim().MD5_pass_kieu1();
            nn.MatKhauReset = txtmk_new.Text.Trim();
            db.SubmitChanges();
            lblstatus.ForeColor = System.Drawing.Color.Green;
            lblstatus.Text = "Đổi mật khẩu thành công";
            Response.AddHeader("REFRESH", "2;URL=../Logout.aspx?flag=1");
        }
        else
        {
            lblstatus.ForeColor = System.Drawing.Color.Red;
            lblstatus.Text = "Mật khẩu không tồn tại";
        }
    }
}